// subtool/pages/treatmentTool/index/index.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    treatmentList:[]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
      this.xInit()
  },
  // 获取所有工具包
  xInit(){
    let that =this
    wx.cloud.callFunction({
      name: 'digital_therapy_extend',
      data: {
          action: "get_all_treatment_item"
      }
    }).then(res => {
        for(let index in res.result){
          res.result[index].cover_img = that.setImg(  res.result[index].data.num )
        }
        that.setData({
          treatmentList:res.result
        })
    })
  },
  // 根据不同的任务类型跳转相应功能页面
  xToToolDetail(e){
      let param = e.currentTarget.dataset
      if(param.num ==7){
        wx.navigateTo({
          url: '/subsale/pages/product/targetMilepost/index?week=0&day=0&treatment_item_id='+ param.id +'&type=1',
        })
      }else if(param.num ==11){
        wx.navigateTo({
          url: '/subtool/pages/communication/index/index?treatment_item_id='+ param.id +'&type=1'+'&week=0&today_communication_skills_status='+false
        })
      }else if(param.num==2){
        wx.navigateTo({
          url: '/subtool/pages/dayremb/detail/index?id=' + param.id + '&num=' + param.writing_class_number + '&week=0&title=' + param.name+'&day=0&treatment_item_id='+param.id +'&type=1',
        })
      }else if(param.num==6){
        wx.navigateTo({
          url: '/subsale/pages/product/paindiary/index?week=0&day=0&treatment_item_id='+ param.id +'&index=0&type=1',
        })
      }else if(param.num ==4 || param.num==5){
        wx.navigateTo({
          url: '/subtool/pages/action/index/index?week=0&treatment_item_id='+param.id+'&type=1',
        })
      }else if( param.num ==8 || param.num ==12){
        wx.navigateTo({
          url: '/subtool/pages/relaxaudioall/index/index?week=0&treatment_item_id='+param.id+'&type=1'+'&num='+param.num,
        })
      }else if(param.num==9){
        wx.navigateTo({
          url: '/subtool/pages/treatmentlist/index/index?treatment_item_id='+ param.id+'&type=1'
        })
      }else if(param.num ==13){
        wx.navigateTo({
          url: '/subuser/pages/research/index?treatment_item_id='+  param.id+'&week=0',
        })
      }else if(param.num==10){
        wx.navigateTo({
          url: '/subtool/pages/pressuresource/index/index?treatment_item_id='+ param.id +'&type=1'+'&week=0&today_pressure_source_status='+false
        })
      }else if(param.num ==3) {
        if(param.file_type ==1){
          wx.navigateTo({
            url: '/subtool/pages/rudio/detail/index?treatment_item_id='+ param.id +'&week=0&audio_id='+param.audio_id
          })
        }else{
          wx.navigateTo({
            url: '/subtool/pages/video/index/index?treatment_item_id='+ param.id +'&week=0&audio_id='+param.audio_id
          })
        }
        
      }else if(param.num ==16) {
        wx.navigateTo({
          url: '/subsale/pages/techevl/index/index?treatment_item_id='+ param.id +'&week=0'
        })
        
      }
  },
  setImg(num){
    if(num == 2 || num == 6 || num == 13){
      return 'https://7633-v3-92ah4-1300208657.tcb.qcloud.la/static/task_rj.svg'
    }else if(num == 7){
      return  'https://7633-v3-92ah4-1300208657.tcb.qcloud.la/static/task_mb.svg'
    }else if(num == 11){
      return 'https://7633-v3-92ah4-1300208657.tcb.qcloud.la/static/task_gt.svg'
    }else if(num == 5 || num == 4){
      return 'https://7633-v3-92ah4-1300208657.tcb.qcloud.la/static/task_xh.svg'
    }else if(num == 8){
      return 'https://7633-v3-92ah4-1300208657.tcb.qcloud.la/static/task_fs.svg'
    }else if(num == 9){
      return 'https://7633-v3-92ah4-1300208657.tcb.qcloud.la/static/task_zl.svg'
    }else if(num == 10){
      return 'https://7633-v3-92ah4-1300208657.tcb.qcloud.la/static/task_yly.svg'
    }else if(num == 12){
      return 'https://7633-v3-92ah4-1300208657.tcb.qcloud.la/static/task_zn.svg'
    }else if(num ==3) {
      return 'https://7633-v3-92ah4-1300208657.tcb.qcloud.la/static/task_zn.svg'
    }else if(num ==16) {
      return 'https://7633-v3-92ah4-1300208657.tcb.qcloud.la/static/task_rj.svg'
    }
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})